import {defineStore} from 'pinia'

interface IState{
    data:Array<IData>
}
interface IData{
    id:number,
    img:string,
    status:string,
    title:string,
    jingnames:string,
    time:string,
    hot:string,
    flag:number
}

const useLive = defineStore('useLive',{
    state:()=><IState>({
        data:[{}],
    }),
    actions:{
        setLiveData(res:Array<IData>){
            this.data = res;
        },
        setFlag(id:number,flag:number){
            const index = this.data.findIndex(item=>item.id===id);
            if(flag){
                this.data[index].flag =0
            }else{
                this.data[index].flag =1
            }
        }
    },
    getters:{

    }
})

export default useLive;